package util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class MyUtils {

	public static void efficiencyTest(int times, Object obj, Method method, Object... args) {

		long start = System.currentTimeMillis();
		try {
			for (int i = 0; i < times; i++) {
				method.invoke(obj, args);
			}
		} catch (IllegalArgumentException e) {
			throw new RuntimeException(e);
		} catch (IllegalAccessException e) {
			throw new RuntimeException(e);
		} catch (InvocationTargetException e) {
			throw new RuntimeException(e);
		}
		long end = System.currentTimeMillis();
		System.out.println(end - start + "ms");
	}

	public static String getString() throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		String s = br.readLine();
		return s;
		// return new BufferedReader(new
		// InputStreamReader(System.in)).readLine();
	}

	public static int getInt() throws IOException {
		// return new DataInputStream(System.in).readInt(); ���
		String s = getString();
		return Integer.parseInt(s);
	}

	public static char getChar() throws IOException {
		// return new DataInputStream(System.in).readChar(); ���
		String s = getString();
		return s.charAt(0);
	}

	public static int[] randomArray(int length, int range) {
		int[] a = new int[length];

		/*
		 * Random rand = new Random(); for (int i=0;i<a.length;i++) {
		 * a[i]=rand.nextInt(range); }
		 */

		for (int i = 0; i < a.length; i++) {
			a[i] = (int) (Math.random() * range);
		}

		return a;
	}

	public static void printArray(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
		System.out.println();
	}

}
